﻿@{
}
<section class="container-fluid m15_t">
    <div class="data-wrap case">
        <form class="form-inline" id="formSearch" onsubmit="return false;">
            <div class="data-tool clearfix">
                <div class="pull-left form-inline ">
                    <input class="hide" name="file" id="upfile" type="file" />
                    <a class="btn btn-default btn-sm m10_l" data-modal="/IpTable/Edit" data-title="新增" data-confirmname="确认" data-width="500" data-height="350"><span class="glyphicon glyphicon-plus"></span> 新增</a>
                </div>
                <div class="pull-right">
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">IP：</label>
                        <input class="form-control" name="ips" type="text" autocomplete="off">
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">账号：</label>
                        <input class="form-control" name="account" type="text" autocomplete="off">
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">分组：</label>
                        <input class="form-control" name="grounpname" type="text" autocomplete="off">
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">系统：</label>
                        <select name="type" class="form-control">
                            <option value="-1">选择类型</option>
                            @{
                                foreach (var item in (IDictionary<int, string>)ViewBag.SystemType)
                                {
                                    <option value="@(item.Key)">@(item.Value)</option>
                                }
                            }
                        </select>
                    </div>

                    <button type="button" class="btn btn-default btn-sm active gettext" id="btnSearch">搜索</button>
                </div>
            </div>
        </form>


        <div class="data-easyui data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table" id="pager"></table>
                </div>
            </div>
        </div>
    </div>
</section>
@section footerScript{

    <script type="text/javascript">

        var pageSize = 10;

        $(function () {
            FlashPay.UI.DataAutoHeight();

            doSearch();

            $("#btnSearch").click(function () {
                doSearch();
            });
        });


        function Tip_success(word) {
            FlashPay.UI.Tip_success(word);
        }

        function getParams() {
            var params = $("#formSearch").serializeJSON();
            return params;
        }

        function doSearch() {
            $("#pager").datagrid({
                fit: false,
                loadMsg: '数据加载中，请稍后……',
                method: "get",
                border: true,
                url: '/IpTable/IpListQuery',
                queryParams: getParams(),
                pagination: true,
                pageSize: pageSize,
                pageList: [10, 15, 30, 50, 100, 1000],
                height: $(window).height() - 70,
                singleSelect: true,
                rownumbers: true,
                showFooter: true,
                idField: 'Id',
                onLoadSuccess: function () {
                    pageSize = $('#pager').datagrid('options').pageSize;
                },
                columns: [[
                    //{
                    //    field: 'id',
                    //    title: "序号",
                    //    width: 75,
                    //    align: 'left',
                    //},
                    {
                        field: 'grounpName',
                        title: '分组',
                        width: 100,
                        align: 'right'
                    },
                    {
                        field: 'account',
                        title: '账号',
                        width: 125,
                        align: 'right',
                    },
                    {
                        field: 'ips',
                        title: 'IP',
                        width: 120,
                        align: 'left'
                    },
                    {
                        field: 'type',
                        title: '系统',
                        width: 120,
                        align: 'left',
                        formatter: function (value, row, index) {
                            var typeStr = "";
                            var types = [
                                { value: 0, Text: '后台管理' },
                                { value: 1, Text: '商户管理' },
                                { value: 2, Text: '付款API' },
                                { value: 3, Text: '收款API' },
                            ];
                            var typeFindResult = types.find(x => { return x.value === value; });
                            if (typeFindResult) {
                                typeStr += typeFindResult.Text;
                            }
                            return typeStr;
                        }
                    },
                    {
                        field: 'remark',
                        title: '备注',
                        width: 120,
                        align: 'left'
                    },
                    {
                        field: 'status',
                        title: '状态',
                        width: 120,
                        align: 'left',
                        formatter: function (value, row, index) {
                            var statusStr = "";
                            var status = [
                                { value: 0, Text: '禁用' },
                                { value: 1, Text: '启用' },
                            ];
                            var statusFindResult = status.find(x => { return x.value === value; });
                            if (statusFindResult) {
                                statusStr += statusFindResult.Text;
                            }
                            return statusStr;
                        }
                    },
                    {
                        field: '_operate',
                        title: "操作",
                        width: 125,
                        align: 'center',
                        formatter: function (value, row, index) {
                            var buttonStr = '<a href="javascript:void(0)" class="btn btn-default btn-xs" data-modal="/IpTable/EditIpTable?Id=' + row.id + '" data-title="编辑" data-width="500" data-height="350"><i class="glyphicon glyphicon-edit"></i> 编辑</a>';
                            buttonStr += '&nbsp;&nbsp;<a href="#" class="btn btn-danger btn-xs" data-confirm="确定要删除此白名单信息？？" data-succesFun="doSearch()" data-href="/IpTable/DelIpTable?id=' + row.id + '" > <i class="glyphicon glyphicon-trash"></i> 删除</a>';
                            return buttonStr;
                        }
                    },
                ]]
            });
        }

    </script>
}


